<?php


class My_View_Helper_showFile extends Zend_View_Helper_Abstract
{
    
    public function showFile($file,$showbasename=true,$array=false,$extra=true)
    {
        
        $ext=$file['extension'];
              
        if (!in_array($ext, array('pdf', 'xls', 'doc', 'docx', 'ppt','dwg','mpp','rar'))) {
            if (in_array($ext, array('gif', 'jpg', 'png', 'bmp'))) 
                $ext = 'image';
            if (in_array($ext, array('zip', '7z', 'tgz', 'gz'))) 
                $ext = 'zip';
            else  
                $ext = 'document';
        }
        
        $img=$this->view->img("img/$ext.png", $file['basename'], array('border'=>0,'title'=>$file['basename']));
        
        $basename=($showbasename) ? '<span class="file_name">'.$file['basename'].'</span>' : '';
        
        $masdatos='';
        if($extra && $basename){
            $masdatos='<span class="file_size"> '.Sgit_Filter_Size::filter($file['size']).'</span>';
            $masdatos.='<span class="file_time"> '.Sgit_Filter_DateDbToLocalize::filter($file['time']).'</span>';
        }

        $archivo= $this->view->anchor($file['public_path'], $img.' '.$basename.$masdatos, array('border'=>0,'target'=>'_blank'));
     
     
     
        if($array==true){
              $file['anchor']=$archivo;
              $file['url']='http://'.$_SERVER['SERVER_NAME'].$file['public_path'];
              $archivo=$file; 
        }
            
       
    	return $archivo;
        
          
    }
}




